let ures = document.querySelector(".ures");
let pwd = document.querySelector(".pwd");
let errures = document.querySelector(".err-ures");
let errpwd = document.querySelector(".err-pwd");
let login = document.querySelector(".login");
//包含数字字母下划线 长度超过六位
let pattern = /^[1-9]([0-9]{5,11})$/;
//以字母开头，长度在6~18之间，只能包含字符、数字和下划线
let pattern2 = /^[a-zA-Z]\w{5,17}$/;

login.onclick = function () {
  if (ures.value == "") {
    errures.innerHTML = "请输入账号!";
    errures.classList.remove("visibility-hidden");
    return;
  } else {
    errures.classList.add("visibility-hidden");
  }
  if (pwd.value == "") {
    errpwd.innerHTML = "请输入密码!";
    errpwd.classList.remove("visibility-hidden");
    return;
  } else {
    errpwd.classList.add("visibility-hidden");
  }

  //正则验证
  console.log(pattern.test(ures.value));
  if (pattern.test(ures.value) == false) {
    errures.innerHTML = "账号格式错误!";
    errures.classList.remove("visibility-hidden");
    return;
  } else {
    errures.classList.add("visibility-hidden");
  }
  if (pattern2.test(pwd.value) == false) {
    errpwd.innerHTML = "密码格式错误!";
    errpwd.classList.remove("visibility-hidden");
    return;
  } else {
    errpwd.classList.add("visibility-hidden");
  }
  login.href = "./meizuHome page.html";
};
$(".tab-title a").click(function () {
    // console.log($(this));
    $(".iui").eq($(this)[0].getAttribute('data-a')).addClass('tab').siblings().removeClass('tab')
    $(this).addClass('active').siblings().removeClass('active');
    $('.main-form .show').eq($(this).index()).addClass('.main-form .show').siblings().removeClass('.main-form .show') 
});
